<?php
	
	
	
	header("Content-Type: application/vnd.ms-word;");
	header("Content-Disposition: attachment; filename=KLGD_".$_GET['maso'].".doc");
	echo "<meta http-equiv='Content-Type' content='text/html; charset=utf-8'>";
	$malophp = $_GET['malophp'];
	include_once('Configs/database.php');
	include_once('Models/CanBo.php');
	include_once('Models/NhatKi.php');
	include_once('Models/LopHocPhan.php');
	include_once('Models/NhomThucHanh.php');
	$nhatki = new NhatKi();;
	$lophp = new LopHocPhan();
	$cb = new CanBo();
	$db = new database();
	$db1 = new database();
	$namhoc = $_GET['namhoc'];
	$hocki = $_GET['hocki'];
	$maso = $_GET['maso'];
	//$namhoc = $_POST['namhoc'];
	//$hocki = $_POST['hocki'];
	//$maso = $_POST['maso'];
	$query = "select distinct tenhp,kihieu,sotc,a.malophp,siso,a.mahp,manhom,sotietlithuyet,sotietthuchanh ";
	$query .= "from LopHocPhan a, HocPhan b ";
	$query .= "where maso='".$maso."' and hocki=".$hocki." and namhoc='".$namhoc."' ";
	$query .= "and a.mahp = b.mahp order by a.mahp ";
	$db->setQuery($query);
	
	echo $db->getQuery();
	$result = $db->fetchAll();
	
	
	$result2 = $db->fetchAll();
	$result3 = $db->fetchAll();
	$result4 = $db->fetchAll();
	$result5 = $db->fetchAll();
	
	$query2 = "select distinct tenhp,c.kihieu,sotc,a.malophp,manhomth,c.siso,a.mahp,manhom,sotietlithuyet,sotietthuchanh ";
	$query2 .= "from LopHocPhan a, HocPhan b,NhomThucHanh c ";
	$query2 .= "where c.maso='".$maso."' and hocki=".$hocki." and namhoc='".$namhoc."' ";
	$query2 .= "and a.mahp = b.mahp and a.malophp=c.malophp order by a.mahp ";
	$db1->setQuery($query2);
	$result1 = $db1->fetchAll();
	$nhomth = new NhomThucHanh();
	
	
	$cb->setQuery("select concat(holot, ' ', ten) as hoten from CanBo where maso='".$maso."'");
	$resultcb = $cb->fetchAll();
	$rowscb = mysql_fetch_array($resultcb);
	$hoten = $rowscb['hoten'];
	
	
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>Untitled Document</title>
</head>

<body>

<p>Nếu thông tin kê khaiCVHT <strong>học kỳ 2-năm học 2009-2010</strong> có sai sót (<strong>thiếu lớp</strong>). Quý cán bộ vui lòng gởi mail đến <strong>lhbinh@ctu.edu.vn </strong>để được kiểm tra lại.<br /> 
  (<strong>Quý cán bộ cần cung cấp đầy đủ thông tin</strong>:<em>Mã số cán bộ và mã số lớp</em>)<br />

  <em>Sau khi xác nhận từ PĐT sẽ cập nhật lại thông tin và thông báo lại đến quý cán bộ. </em></p>
<p align="center"><em><strong>Chi tiết công tác Giảng dạy ĐH, CĐ chính quy - Cán bộ: <b><?php echo $hoten?>(<?php echo $maso?>)</b> </strong></em></p>
<table width="100%" align="center"  cellpadding="0" cellspacing="0" style="border: 1px solid #686;" border="1">
  <tr>
    <td width="4%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>STT</strong></td>
    <td width="24%" rowspan="2" align="center" valign="middle" bgcolor="#DAE9F3"><strong>Nội dungMã HP </strong></td>
    <td width="6%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>Ký hiệu </strong></td>

    <td width="5%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>DVHT</strong></td>
    <td width="5%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>Lớp</strong></td>
    <td width="5%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>Số SV </strong></td>
    <td width="6%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>Số nhóm </strong></td>
    <td width="5%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>Giờ thực tế </strong></td>
    <td width="5%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>Hệ số quy dổi </strong></td>

    <td colspan="3" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>Giờ chuẩn theo học kỳ</strong></td>
    <td width="10%" rowspan="2" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>Tổng số giờ dạy CQ </strong></td>
  </tr>
  <tr>
    <td width="6%" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>HKII</strong></td>
    <td width="4%" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>HK hè </strong></td>
    <td width="4%" align="center" valign="middle"  bgcolor="#DAE9F3"><strong>HKI</strong></td>
  </tr>
  <tr>
    <td align="center" valign="middle"  bgcolor="#DAE9F3">1</td>
    <td colspan="12" align="left" valign="middle" ><strong>Giảng dạy lý thuyết CĐ,ĐH CQ </strong></td>
  </tr>
  <?php
  	$i = 0;
	$tonglthk1 = 0;
	$tonglthk2 = 0;
	$tonglthk3 = 0;
  while ($rows = mysql_fetch_array($result))
  {	
  	
  	$lophp->setMaLopHP($rows['malophp']);
	$tonglthk1 = $tonglthk + $lophp->tongSoTietDaDay();
    $tonglthk2 = $tonglthk + $lophp->tongSoTietDaDay();
    $tonglthk3 = $tonglthk + $lophp->tongSoTietDaDay();
  	//$nhatki->setMaLopHP($rows['malophp']);
  	if ($rows['manhom']==1 || $rows['manhom']==3 )
	{
		$i++;
		$c = 2- $i%2;
  ?>
	  <tr>
		<td align="right" valign="middle"  bgcolor="#DAE9F3">1.<?php echo $i?>&nbsp;</td>
		<td align="left" valign="middle" >&nbsp;&nbsp;<?php echo $rows['tenhp']?></td>
		<td align="center" valign="middle" ><?php echo $rows['kihieu']?></td>
		<td align="center" valign="middle" ><?php echo $rows['sotc']?></td>
		<td align="center" valign="middle" ><?php echo $rows['malophp']?></td>
		<td align="center" valign="middle" ><?php echo $rows['siso']?></td>
		<td align="center" valign="middle" >&nbsp;</td>
		
		<td align="center" valign="middle" ><?php echo $lophp->tongSoTietDaDay();?></td>
		<td align="center" valign="middle" >&nbsp;</td>
		<td align="center" valign="middle" ><?php if ($hocki==2) echo round($lophp->tongSoTietDaDay(),0);?></td>
		<td align="center" valign="middle" ><?php if ($hocki==3) echo round($lophp->tongSoTietDaDay(),0);?></td>
		<td align="center" valign="middle" ><?php if ($hocki==1) echo round($lophp->tongSoTietDaDay(),0);?></td>
		<td align="center" valign="middle" >&nbsp;</td>
	  </tr>
	<?php
		}
	}
	?>
  <tr>
    <td align="center" valign="middle" bgcolor="#DAE9F3">&nbsp;</td>
    <td colspan="8" align="left" valign="middle"><strong>Cộng</strong></td>

    <td align="center" valign="middle"><b>
      <?php if ($hocki==2) echo round($tonglthk2,0);?>
    </b></td>
    <td align="center" valign="middle"><b>
      <?php if ($hocki==3) echo round($tonglthk3,0);?>
    </b></td>
    <td align="center" valign="middle"><b>
      <?php if ($hocki==1) echo round($tonglthk1,0);?>
    </b></td>
    <td align="center" valign="middle">&nbsp;</td>
  </tr>
  <tr>
    <td align="center" valign="middle" bgcolor="#DAE9F3">2</td>
    <td colspan="12" align="left" valign="middle" class='level_1_2'><strong>Dạy thực hành, thí nghiệm </strong></td>
  </tr>
   <?php
		$i = 0;
		$tongthhk1 = 0;
		$tongthhk2 = 0;
		$tongthhk3 = 0;
	  while ($rows = mysql_fetch_array($result1))
	  {
	  	
	  	$nhomth->setMaNhomTH($rows['manhomth']);
		$tongthhk1 = $tongthhk1 + ($nhomth->getHeSo()*$nhomth->tongSoTietDaDay());
		$tongthhk2 = $tongthhk2 + ($nhomth->getHeSo()*$nhomth->tongSoTietDaDay());
		$tongthhk3 = $tongthhk3 + ($nhomth->getHeSo()*$nhomth->tongSoTietDaDay());
		if ($rows['manhom']==2 || $rows['manhom']==3 )
		{
			$i++;
			$c = 2- $i%2;
	  ?>
  <tr>
		<td align="right" valign="middle" bgcolor="#DAE9F3">2.<?php echo $i?>&nbsp;</td>
		<td align="left" valign="middle" >&nbsp;&nbsp;<?php echo $rows['tenhp']?></td>
		<td align="center" valign="middle" ><?php echo $rows['kihieu']?></td>
		<td align="center" valign="middle" ><?php echo $rows['sotc']?></td>
		<td align="center" valign="middle" ><?php echo $rows['manhomth']?></td>
		<td align="center" valign="middle" ><?php echo $rows['siso']?></td>
		<td align="center" valign="middle" >&nbsp;</td>
	
		<td align="center" valign="middle" ><?php echo round($nhomth->getHeSo()*$nhomth->tongSoTietDaDay(),0);?></td>
		<td align="center" valign="middle" >&nbsp;</td>
		<td align="center" valign="middle" ><?php if ($hocki==2) echo round($nhomth->getHeSo()*$nhomth->tongSoTietDaDay(),0);?></td>
		<td align="center" valign="middle" ><?php if ($hocki==3) echo round($nhomth->getHeSo()*$nhomth->tongSoTietDaDay(),0);?></td>
		<td align="center" valign="middle" ><?php if ($hocki==1) echo round($nhomth->getHeSo()*$nhomth->tongSoTietDaDay(),0);?></td>
		<td align="center" valign="middle" >&nbsp;</td>
  </tr>
  	<?php
		}
	}
	?>
  <tr>
    <td align="center" valign="middle" bgcolor="#DAE9F3">&nbsp;</td>
    <td colspan="8" align="left" valign="middle" ><strong>Cộng</strong></td>
    <td align="center" valign="middle" ><b><?php if ($hocki==2) echo round($tongthhk2);?></b></td>
    <td align="center" valign="middle" ><b><?php if ($hocki==3) echo round($tongthhk3);?></b></td>
    <td align="center" valign="middle" ><b><?php if ($hocki==1) echo round($tongthhk1);?></b></td>
    <td align="center" valign="middle" ><?php echo round($tongthhk1 + $tongthhk2 + $tongthhk3);?></td>
  </tr>
  
  
  
</table>

</body>
</html>
